/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package structures;

import music.*;
import music.TimeSignature;

/**
 *
 * @author TJ
 */
public class NotesManager {
    private Voice[] voices;
    public NotesManager(Measure m) {
        voices=new Voice[4];
        for(int i=0; i<4; i++) {
            voices[i]=new Voice(m);
        }
    }
    public Voice[] getVoices(){return voices;}
    public void addNote(Note note,float beat, int voice) {
        for(int i=voice-1; i<3;i++) {
            if(!voices[i].noteExistsIn(beat)) {
                voices[i].addNoteAt(beat, note);
                return;
            }
        }
        voices[3].addNoteAt(beat, note);
    }
    public void removeNote(int voice) {
        
    }
    public void clearAllNotes(){
        for(Voice v : voices) {
            v.clear();
        }
    }
    public void clearVoice(int i) {voices[i-1].clear();}
    public void clearMeasure(){
        for(int i=1; i<=4;i++) {
            clearVoice(i);
        }
    }
    public Voice getVoice(int i) {
        if(i<=0 || i>4) {throw new IllegalArgumentException();}
        return voices[i-1];
    }
}
